package com.homework;

public class Shot implements Runnable{
    private int x;
    private int y;
    private int direction=0;
    private int speed=15;
    boolean isLive=true;
    private Tank tank;
    @Override
    public void run() {
        while (x>=0&&y>=0&&x<=1000&&y<=750&&isLive){
            switch (direction){
                case 0:
                    y-=speed;break;
                case 1:
                    x+=speed;break;
                case 2:
                    y+=speed;break;
                case 3:
                    x-=speed;break;
            }
            try {
                Thread.sleep(50);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        tank.shots.remove(this);
        isLive=false;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public Shot(int x, int y, int direction,Tank tank) {
        this.x = x;
        this.y = y;
        this.direction = direction;
        this.tank=tank;
    }

}
